<template>
  <div>{{ loginMethod }}登录成功！</div>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
const loginMethod = ref('')
const route = useRoute()
// 页面加载时
onMounted(() => {
  console.log('%c页面加载耗时：13ms | Theme By Joe', 'color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px')
  const { code } = route.query
  const qqLogin = route.params.id === 'qq_login'
  const githubLogin = route.params.id === 'github_login'

  if (qqLogin) {
    loginMethod.value = 'QQ'
    window.opener.postMessage(
      {
        type: 'qq_login',
        data: code
      },
      '*'
    )
    window.close()
  }
  if (githubLogin) {
    loginMethod.value = 'GitHub'
    window.opener.postMessage(
      {
        type: 'github_login',
        data: code
      },
      '*'
    )
    window.close()
  }
})
</script>

<style lang="scss" scoped>
@import '@/assets/css/constant.scss';
</style>
